Bezi MS Word ?

Otázka od: Roland Turcan

24. 10. 2002 16:02

Hello Delphi CZ konferencia!

Takto testujem v OnClose formu ci Word bezi

      if WA.Visible then
      begin
        WA.Activate;
        Action := caNone;
        Exit;
      end;

      if WD.Application.Visible then
      begin
        WD.Application.Activate;
        Action := caNone;
        Exit;
      end;
      WD.Disconnect;
      WA.Quit;
      WA.Disconnect;

Ale mi to na Word 8 (97) mi to hlasi chybu
"Server RPC sa odpojil od
svojich klientov".


--
Best regards, TRoland
http://www.rotursoft.sk

Odpovedá: Roland Turcan

24. 10. 2002 19:41

<<< 24. 10. 2002 20:09 - Roland Turcan "rolo@sedas.sk" >>>
RT> Hello Delphi CZ konferencia!

RT> Takto testujem v OnClose formu ci Word bezi

RT> if WA.Visible then
RT> begin
RT> WA.Activate;
RT> Action := caNone;
RT> Exit;
RT> end;

RT> if WD.Application.Visible then
RT> begin
RT> WD.Application.Activate;
RT> Action := caNone;
RT> Exit;
RT> end;
RT> WD.Disconnect;
RT> WA.Quit;
RT> WA.Disconnect;

RT> Ale mi to na Word 8 (97) mi to hlasi chybu
"Server RPC sa odpojil od
RT> svojich klientov".

Nasiel som na internete:

uses
  ComObj, ActiveX;

function IsObjectActive(ClassName: string): Boolean;
var
  ClassID: TCLSID;
  Unknown: IUnknown;
begin
  try
    ClassID := ProgIDToClassID(ClassName);
    Result := GetActiveObject(ClassID, nil, Unknown) = S_OK;
  except
    // raise;
    Result := False;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if IsObjectActive('Word.Application') then ShowMessage('Word is running !');
  if IsObjectActive('Excel.Application') then
ShowMessage('Excel is running !');
  if IsObjectActive('Outlook.Application') then
ShowMessage('Outlook is running !');
  if IsObjectActive('Access.Application') then
ShowMessage('Access is running !');
  if IsObjectActive('Powerpoint.Application') then
ShowMessage('Powerpoint is running !');
end;

Mozno to pomoze aj ostatnym.



--
Best regards, TRoland
http://www.rotursoft.sk